﻿using System;
using HiTeachers.Services;

namespace HiTeachers.Web
{
    public partial class StudentRequestDetails : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack) return;

            var itemId = new Guid(Request["itid"]);
            var request = StudentRequestServices.GetById(itemId);

            Page.Title = string.Format("{0} - {1}", SitePreFix, request.Title);
            ltrTitleNews.Text = request.Title;
            ltrPublishedDate.Text = request.PostedDate.ToString("dd/MM/yyyy, hh:mm tt", System.Globalization.CultureInfo.InvariantCulture);
            ltrContent.Text = request.Content;


            ltrName.Text = request.Name;
            ltrAddress.Text = string.Format("Quận {0}, TP {1}", request.District, request.City);
            ltrFees.Text = (request.Fees > 0) ? request.Fees.ToString("#,#") : "Thỏa thuận";

            rptOther.DataSource = StudentRequestServices.GetRelationStdRequests(itemId, request.PostedDate, 5);
            rptOther.DataBind();

            Page.Title = string.Format("{0} - {1}", SitePreFix, request.Title);
            if (!Page.User.Identity.IsAuthenticated)
                btnContact.Text = "Đăng nhập";
            else
                btnContact.Text = !CurrentUser.IsFullAccount ? "Nâng cấp" : "Liên hệ";
        }

        protected void BtnContactClick(object sender, EventArgs e)
        {
            var itemId = Request["itid"];
            Response.Redirect(string.Format("Contact2Student.aspx?itid={0}", itemId));
        }
    }
}
